<?php

/**
 * QaController class
 *
 * @author Julot
 * @since Friday, May 25, 2012. 11:12 PM
 */
class QaController extends CController {

	/**
	 * @property string the default layout for the controller view.
	 * Defaults to '//layouts/column1', meaning using a single column layout.
	 * See 'protected/views/layouts/column1.php'.
	 */
	public $layout = '//layouts/column1';

	/**
	 * @property array context menu items. This property will be assigned to
	 * {@link CMenu::items}.
	 */
	public $menu = array();

	/**
	 * @property array the breadcrumbs of the current page.
	 * The value of this property will be assigned to
	 * {@link CBreadcrumbs::links}.
	 * Please refer to {@link CBreadcrumbs::links} for more details on how to
	 * specify this property.
	 */
	public $breadcrumbs = array();

	public function mail($from, $subject, $message) {
		if (YII_DEBUG) return;

		$admins = array();
		foreach (Yii::app()->getModule('qa')->admins as $admin) {
			if (stripos($admin, $from) === false) {
				$admins[] = $admin;
			}
		}
		if ($admins) {
			$headers = "MIME-Version: 1.0\r\n";
			$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
			$headers .= "From: $from\r\n";
			$headers .= "Reply-To: $from";
			$to = implode(', ', $admins);
			mail($to, $subject, $message, $headers);
		}
	}

}
